package com.selfdriving.adapter;

import java.util.List;
import com.selfdriving.R;
import com.selfdriving.bean.User;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class PersonAdapter extends BaseAdapter {
private Context context;

private List<User> users;

private HolderView holderView;

	public PersonAdapter(Context context,List<User> users) {
		this.context =context;
		this.users =users;
}

	@Override
	public int getCount() {
		return users.size();
	}

	@Override
	public Object getItem(int position) {
		return users.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup arg2) {
		if (view == null) {
			holderView = new HolderView();
			view = ((LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
					.inflate(R.layout.person_item, null);
			view.setTag(holderView);
		} else {
			holderView = (HolderView) view.getTag();
		}
		return view;
	}
	
	private class HolderView{
		private ImageView icon;
		
		private TextView distance;
		
		private ImageView sex;
	}

}
